package im.redis.client.operations;

import java.util.Set;

import im.redis.client.JedisTemplate;
import im.redis.client.JedisTemplate.JedisAction;
import redis.clients.jedis.Jedis;

public class SetOperation {
	private JedisTemplate template;

	public SetOperation(JedisTemplate template) {
		super();
		this.template = template;
	}

	// / Set Actions ///
	public Boolean sadd(final String key, final String member) {
		return template.execute(new JedisAction<Boolean>() {

			@Override
			public Boolean action(Jedis jedis) {
				return jedis.sadd(key, member) == 1 ? true : false;
			}
		});
	}

	public Set<String> smembers(final String key) {
		return template.execute(new JedisAction<Set<String>>() {

			@Override
			public Set<String> action(Jedis jedis) {
				return jedis.smembers(key);
			}
		});
	}

}
